package com.chengym.easy.dockerservice.common.config.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;

@Controller
@RequestMapping("config")
@Slf4j
@RefreshScope //nacos的config的配置，用到@Value的地方需要加上
public class ConfigController {
    @Value("${configTestStr:false}")
    private String configTestStr;

    @GetMapping(value = "/get")
    @ResponseBody
    public String get() {
        return configTestStr;
    }
    @PostConstruct
    public void checkConfig(){
        log.info("nacos config check is {}",configTestStr);
    }
}
